package cn.eric.framework.auth.domain;

import javax.persistence.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import java.util.List;

@Entity
@Table(name = "e_role")
@XmlAccessorType(XmlAccessType.NONE)
public class Role {
    @Id
    @Column(name = "role_id")
    @XmlAttribute(name = "id")
    private String roleId;
    @Column(name = "role_name")
    @XmlAttribute(name = "name")
    private String roleName;
    @CollectionTable(name = "e_role_authority_ids")
    @ElementCollection(targetClass = String.class, fetch = FetchType.EAGER)
    @OrderColumn(name = "idx")
    @XmlElement(name = "authorityId")
    private List<String> authorityIds;

    @Override
    public String toString() {
        return "Role{" +
                "roleId='" + roleId + '\'' +
                ", roleName='" + roleName + '\'' +
                ", authorityIds=" + authorityIds +
                '}';
    }

    public String getRoleId() {
        return roleId;
    }

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public List<String> getAuthorityIds() {
        return authorityIds;
    }

    public void setAuthorityIds(List<String> authorityIds) {
        this.authorityIds = authorityIds;
    }
}
